package com.mall.user.common.exception;

import com.mall.user.common.response.ResultCode;
import lombok.Getter;
import lombok.Setter;

/**
 * 业务异常类
 */
@Setter
public class BusinessException extends RuntimeException {

    /**
     * 错误码
     */
    @Getter
    private Integer code;

    /**
     * 错误消息
     */
    private String message;

    public BusinessException(ResultCode ResultCode) {
        super(ResultCode.getMessage());
        this.code = ResultCode.getCode();
        this.message = ResultCode.getMessage();
    }

    public BusinessException(ResultCode ResultCode, String message) {
        super(message);
        this.code = ResultCode.getCode();
        this.message = message;
    }

    @Override
    public String getMessage() {
        return message;
    }

}